/**
 * Auto gen via dbpojo-gen.
 */
package com.us.usws.site.console.action;

import java.util.List;

import javax.inject.Inject;

import org.apache.commons.lang3.StringUtils;

import com.us.usws.model.domain.video.VideoExtattr;
import com.us.usws.service.cud.VideoExtattrCUDService;
import com.us.usws.service.ro.VideoExtattrROService;
import com.us.usws.support.uitls.JSONDataUtil;

/**
 * Struts2 action
 * @author robot
 */
public class VideoExtattrAction extends BasePageSearchAction<VideoExtattr> {

	private static final long serialVersionUID = 1L;

	private VideoExtattr videoExtattr;

	@Inject
	private VideoExtattrROService videoExtattrROService;

	@Inject
	private VideoExtattrCUDService videoExtattrCUDService;

	private String uids;

	/**
	 * ajax load the list of VideoExtattr
	 */
	public void ajaxLoadVideoExtattrs() {
		createDataPageUtil();
		List<VideoExtattr> videoExtattrs = videoExtattrROService.getVideoExtattrs(getStart(), getLimit());
		getOut().println(JSONDataUtil.extJsonSupportPage(videoExtattrs, dataPageUtil.getRowCount()));
	}

	/**
	 * ajax update VideoExtattr
	 */
	public void ajaxUpdateVideoExtattr() {
		if (videoExtattr != null) {
			String uid = videoExtattr.getUid();
			if (StringUtils.isNotBlank(uid)) {
				videoExtattrCUDService.updateVideoExtattr(videoExtattr);
			} else {
				videoExtattrCUDService.addVideoExtattr(videoExtattr);
			}
			getOut().print(true);
		} else {
			getOut().print(false);
		}
	}

	/**
	 * ajax delete user.
	 */
	public void ajaxDeleteVideoExtattr() {
		videoExtattrCUDService.deleteVideoExtattrMore(uids);
	}

	public void setVideoExtattr(VideoExtattr videoExtattr) {
		this.videoExtattr = videoExtattr;
	}

	public VideoExtattr getVideoExtattr() {
		return videoExtattr;
	}

	public String getUids() {
		return uids;
	}

	public void setUids(String uids) {
		this.uids = uids;
	}

}